﻿using System;
using System.Collections.Generic;
using System.Text;
using TTServer.Objects;

using libReadWrite;
using libCommonClass;

namespace TTServer.Messages
{
    public class FileDetailsResponseMessage : TTMessage
    {
        private CFileDetail fileDetails = new CFileDetail();

        public FileDetailsResponseMessage(CFileDetail fd)
        {
            fileDetails.Name = fd.Name;
            fileDetails.Lenght = fd.Lenght;
            fileDetails.DirectoryFullPath = fd.DirectoryFullPath;
            fileDetails.CreationTime = fd.CreationTime;
            fileDetails.LastAccessTime = fd.LastAccessTime;
            fileDetails.LastWriteTime = fd.LastWriteTime;
        }

        public FileDetailsResponseMessage()
        {
            
        }

        public override void ReadMessage(BigEndianReader sr)
        {
            throw new NotImplementedException();
        }

        public override void WriteMessage(BigEndianWriter sw)
        {
            sw.Write((byte)MessageKind.FILE_DETAILS_RESPONSE);
            sw.Write(Global.NO_LENGTH_CODE);

            sw.WriteString(fileDetails.Name);
            sw.Write(fileDetails.Lenght);
            sw.WriteString(fileDetails.DirectoryFullPath);
            sw.WriteString(fileDetails.CreationTime);
            sw.WriteString(fileDetails.LastAccessTime);
            sw.WriteString(fileDetails.LastWriteTime);
            
        }

        public override TTMessage Clone()
        {
            return new FileDetailsResponseMessage();
        }

        public override int GetMessageID()
        {
            return MessageKind.FILE_DETAILS_RESPONSE;
        }

        public override string GetMessageName()
        {
            return "FileDetailsResponseMessage";
        }
    }
}
